import 'package:flutter/material.dart';
import 'package:flutterproject/mvvm/base/base_state.dart';
import 'package:flutterproject/page/setting/children/upgrade/controller/upgrade_controller.dart';
import 'package:flutterproject/util/extension/extension_util.dart';
import 'package:flutterproject/util/extension/widget_extension.dart';
import 'package:flutterproject/util/margin_padding_util.dart';
import 'package:flutterproject/widget/image_extended.dart';
import 'package:flutterproject/widget/text/text_common.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';

class UpgradePage extends BaseState<UpgradeController> {
  @override
  UpgradeController initController() => UpgradeController();

  @override
  Widget initView(BuildContext context) {
    return Container(
      color: Color(0xFFF6F6F6),
      width: Get.width,
      height: Get.height,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          72.heightBox,
          Padding(
            padding: MarginPaddingUtil.only(left: 42),
            child: ImageCommon(
              "/icon/ic_left",
              width: 21.width,
              height: 36.width,
            ),
          ).addClickEvent(() {
            Get.back();
          }),
          57.heightBox,
          SizedBox(
            width: Get.width,
            child: Column(
              children: [
                ImageCommon(
                  "/icon/ic_logo",
                  size: 136.width,
                ),
                28.heightBox,
                GetBuilder<UpgradeController>(
                    id: 'version',
                    builder: (logic) {
                      return TextCommon(
                        "版本号：V${controller.version}",
                        color: Color(0xFF242429),
                      );
                    }),
              ],
            ),
          ),
          50.heightBox,
          Container(
            width: Get.width,
            margin: MarginPaddingUtil.symmetric(horizontal: 26),
            padding: MarginPaddingUtil.symmetric(vertical: 50, horizontal: 32),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(20.radius),
            ),
            child: Column(
              children: [
                Row(
                  children: [
                    TextCommon(
                      "版本更新",
                      size: 28.sp,
                      color: Color(0xFF242429),
                    ),
                    Spacer(),
                    TextCommon(
                      "已是最新版本",
                      color: Color(0xFF242429).withOpacity(0.3),
                    )
                  ],
                ).addClickEvent(() => controller.checkUpgrade()),
                39.heightBox,
                Divider(
                  color: Color(0xFFE4E9EB),
                  height: 1.width,
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
